package com.xbongbong.pro.menu.pojo.dto;

import com.xbongbong.paas.enums.DelEnum;
import com.xbongbong.paas.toolbox.wrap.BaseDTO;
import com.xbongbong.paas.toolbox.wrap.QueryIgnore;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;

/**
 * 菜单 & 应用开关接口DTO
 * @author kaka
 * @time 2019-1-4 15:18
 */
@Setter
@Getter
@ToString
public class MenuChangeStateDTO extends BaseDTO {

    private static final long serialVersionUID = 2045552602371932966L;


    /**
     * 指定接口参数类型，1 表示应用，2 表示菜单
     */
    @NotNull(message = "{dto.msg.menuChangeState.target.NotNull}")
    @Range(min = 1, max = 2, message = "{dto.msg.menuChangeState.target.Range}")
    @Getter(onMethod_ = {@QueryIgnore})
    private Integer target;

    /**
     * 应用id
     */
    @NotNull(message = "{dto.msg.menuChangeState.appId.NotNull}")
    @Getter(onMethod_ = {@QueryIgnore})
    private Long appId;

    private Long appModuleId;

    /**
     * 菜单id
     */
    @Getter(onMethod_ = {@QueryIgnore})
    private Long menuId;

    /**
     * 别名
     */
    private String alias;

    /**
     * 开启或关闭
     * true 表示开启，false表示关闭
     */
    @NotNull(message = "{dto.msg.menuChangeState.enable.NotNull}")
    @Getter(onMethod_ = {@QueryIgnore})
    private Boolean enable;

    private Integer del;

    public MenuChangeStateDTO() {
        del = DelEnum.NORMAL.getDel();
    }
    /**
     * target 值对应的枚举
     */
    @Getter(onMethod_ = {@QueryIgnore})
    public enum TargetEnum {

        /**
         * 开启/关闭对象为应用
         */
        APP(1, "应用"),

        /**
         * 开启/关闭对象为菜单
         */
        MENU(2, "菜单"),
        ;
        /**
         * target值
         */
        private int code;

        /**
         * target名称
         */
        private String name;

        TargetEnum(int code, String name) {
            this.code = code;
            this.name = name;
        }
    }
}
